"use strict";

$(function () {
  window.onload = function () {
    // 侧边栏的点击头部效果
    $("#top").click(function () {
      $("html").animate(
        {
          scrollTop: 0,
        },
        1000
      );
    });

    // 渲染
    $.ajax({
      url: "http://localhost:3000/api/list/goods",
      success: function success(res) {
        res = res.data;
        recommend(res);
        products(res);
      },
    });

    $.ajax({
      url: "http://localhost:3000/api/list/crowdfoundin",
      success: function success(res) {
        // console.log(res);
        res = res.data;
        crowdfoundin(res);
      },
    });
    $.ajax({
      url: "http://localhost:3000/api/list/crowdfoundin",
      success: function success(res) {
        res = res.data;
        crowdfoundin2(res);
      },
    });
  }; //渲染每日新品列表

  function products(res) {
    var str = "";

    for (var i = 23; i < 27; i++) {
      str += '\n          <div class="New-products-list">\n            <a href="particular.html?id='
        .concat(res[i].id, '">\n              <img src="')
        .concat(
          res[i].src1,
          '" alt="" />\n              <div class="New-products-t1">'
        )
        .concat(
          res[i].name,
          '</div>\n              <div class="New-products-t2">'
        )
        .concat(
          res[i].intro,
          '</div>\n              <div class="New-products-t3">'
        )
        .concat(
          res[i].price,
          "</div>\n            </a>\n          </div>\n          "
        );
    } // console.log($('.New-products-main'));

    $(".New-products-main").html(str);
  } //渲染全列表

  function recommend(res) {
    var str = "";

    for (var i = 7; i < 27; i++) {
      str += '\n          <div class="recommend-list">\n          <a href="particular.html?id='
        .concat(
          res[i].id,
          '">\n            <div class="recommend-list-top ">\n              <img src="'
        )
        .concat(
          res[i].src1,
          '" alt="" />\n              <div class="recommend-list-t1">'
        )
        .concat(
          res[i].intro,
          '</div>\n            </div>\n            <div class="recommend-list-main">\n              <div class="recommend-l '
        )
        .concat(res[i]["class"], '">')
        .concat(
          res[i].special,
          '</div>\n              <div class="recommend-list-t3">'
        )
        .concat(
          res[i].name,
          '</div>\n              <div class="recommend-list-t4">'
        )
        .concat(
          res[i].price,
          "</div>\n            </div>\n            </a>\n          </div>\n          "
        );
    } // console.log($('.recommend-mai'));

    $(".recommend-main").html(str);
  } //有品众筹左

  function crowdfoundin(res) {
    var str = "";

    for (var i = 0; i < 1; i++) {
      str += '\n      <a href="particular.html?id='
        .concat(
          res[i].id,
          '">\n      <li class="crowdfoundin-list1 fl">\n           <div class="cr-w-01">\n              <ul>\n                <li>\n                  <p class="cr-t-01">'
        )
        .concat(res[i].name, '</p>\n                  <p class="cr-t-02">')
        .concat(res[i].intro, '</p>\n                  <p class="cr-t-03">')
        .concat(
          res[i].price,
          '</p>\n                </li>\n                <li><img src="'
        )
        .concat(
          res[i].src1,
          '" alt="" /></li>\n              </ul>\n            </div>\n            <div class="cr-w-02"></div>\n            <div class="cr-w-03">\n              <div class="cr-l-01">'
        )
        .concat(
          res[i].stand_by,
          '<span>\u4EBA\u652F\u6301</span></div>\n              <div class="cr-l-02">\u7206</div>\n              <div class="cr-l-03">'
        )
        .concat(
          res[i].stand_bys,
          "</div>\n            </div>\n            </div>\n          </a>\n          "
        );
    }

    $(".crowdfoundin-main-left").html(str);
  } //有品众筹右

  function crowdfoundin2(res) {
    var str = "";

    for (var i = 1; i < 3; i++) {
      str += '\n              <a href="particular.html?id='
        .concat(
          res[i].id,
          '">\n                <li class="crowdfoundin-list2 fl">\n                  <div class="cr-w-01">\n                    <ul>\n                      <li>\n                      <p class="cr-t-01">'
        )
        .concat(res[i].name, '</p>\n                      <p class="cr-t-03">')
        .concat(
          res[i].price,
          '</p>\n                      </li>\n                      <li><img src="'
        )
        .concat(
          res[i].src1,
          '" alt="" /></li>\n                    </ul>\n                  </div>\n                  <div class="cr-w-02"></div>\n                    <div class="cr-w-03">\n                    <div class="cr-l-01">'
        )
        .concat(
          res[i].stand_by,
          '<span>\u4EBA\u652F\u6301</span></div>\n                    <div class="cr-l-02">\u7206</div>\n                    <div class="cr-l-03">'
        )
        .concat(
          res[i].stand_bys,
          "</div>\n                  </div>\n                </li>\n              </a> \n          "
        );
    }

    $(".crowdfoundin-main-right").html(str);
  }
});
("use strict");

$(function () {
  //首页旅游产品分类
  $(".product_sort .bd .item").hover(
    function () {
      $(this).addClass("layer");
    },
    function () {
      $(this).removeClass("layer");
    }
  );
});
